#ifndef _SMTPCHANNEL_HPP_
#define _SMTPCHANNEL_HPP_

#include "jhdefs.hpp"
#include "log/channel.hpp"
#include "log/message.hpp"
#include "charset/string.hpp"
using namespace JHCPP::charset;
using JHCPP::log::CChannel;
using JHCPP::log::CMessage;
#include <string>

NET_NAMESPACE_BEGIN

class CSMTPChannel : public CChannel
{
public:
	CSMTPChannel();
	CSMTPChannel(const std::string& mailhost, const std::string& sender, const std::string& recipient);

	void open();
	void close();

	void log(const CMessage& msg);

	void setProperty(const std::string& name, const std::string& value);
	std::string getProperty(const std::string& name) const;

	static void registerChannel();

	static const std::string PROP_MAILHOST;
	static const std::string PROP_SENDER;
	static const std::string PROP_RECIPIENT;
	static const std::string PROP_LOCAL;
	static const std::string PROP_ATTACHMENT;
	static const std::string PROP_TYPE;
	static const std::string PROP_DELETE;
	static const std::string PROP_THROW;

protected:
	~CSMTPChannel();

private:
	bool isTrue(const std::string& value) const;

	std::string m_mailHost;
	std::string m_sender;
	std::string m_recipient;
	bool        m_local;
	std::string m_attachment;
	std::string m_type;
	bool        m_delete;
	bool        m_throw;
};

NET_NAMESPACE_END

#endif
